// JavaScript Document
$(document).ready(function (e) {
    $("#open").click(function () {
        $("#hidden_panel").slideDown("slow");
    });
    $("#close").click(function () {
        $("#hidden_panel").slideUp("slow");
    });
    $("#toggle a").click(function () {
        $("#toggle a").toggle();
    });
    $("ul.left_menu li").hover(function () {
        $(this).find("a").stop().animate({ "width": "185" });
        $(this).find("ul:first").show(400);
    }, function () {
        $(this).find("ul:first").hide(400);
        $(this).find("a").stop().animate({ "width": "166" });
    });

    var currentPosition = 0;
    var slideWidth = 500;
    var slides = $('.slide');
    var numberOfSlides = slides.length;
    $('#slide_container').css('overflow', 'hidden');
    slides.wrapAll('<div id="slideInner"></div>').css({ 'float': 'left', 'width': slideWidth });
    $('#slideInner').css('width', slideWidth * numberOfSlides);
    $('#slide_show').prepend('<span class="control" id="leftControl"></span>').append('<span class="control" id="rightControl"></span>');
    manageControls(currentPosition);
    $('.control').bind('click', function () {
        currentPosition = ($(this).attr('id') == 'rightControl') ? currentPosition + 1 : currentPosition - 1;
        manageControls(currentPosition);
        $('#slideInner').animate({ 'marginLeft': slideWidth * (-currentPosition) });
    });
    function manageControls(position) {
        if (position == 0) {
            $('#leftControl').hide()
        }
        else {
            $('#leftControl').show()
        }
        if (position == numberOfSlides - 1) {
            $('#rightControl').hide()
        }
        else {
            $('#rightControl').show()
        }
    }
});